package com.itheima.filter;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

/**
 * @Author: 祺诺
 * @Name; xqf
 * @Date: 2020/12/26 20:37
 */
@WebFilter("/*")
public class CharacterEncodingFilter implements Filter {
    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        //设置请求的编码表
        servletRequest.setCharacterEncoding("utf-8");
        //设置响应的编码表
        servletResponse.setContentType("text/html;charset=utf-8");
        //返还
        filterChain.doFilter(servletRequest,servletResponse);
    }
}
